

clear
 use Data/event_study_samplewithsolar.dta

gen solaryear=year(solar_start_date)
	gen solarmonth = month(solar_start_date)
	gen solarquarter =1 if solarmonth < = 3
	replace solarquarter =2 if solarmonth > 3 & solarmonth < =6
	replace solarquarter = 3 if solarmonth > 6 & solarmonth <=9
	replace solarquarter = 4 if solarmonth >9 & solarmonth <=12

	gen solar_quarter = yq(solaryear,solarquarter)
	format solar_quarter %tq
	

	collapse (firstnm) solar_quarter adopted_solar postcode (lastnm) has_solar (mean) ever_solar green_plan mean_weighted discounted_price module price* network_tariff year NCustomers cum new *_interp unitprice houseprice area *ROOF*  , by(account_id contract_quarter)



gen pre_solar = ever_solar ==1 & has_solar ==0 
replace pre_solar=. if has_solar==1


label variable has_solar "Has Solar Panels"
label variable adopted_solar ""

 reg green_plan has_solar#adopted_solar , cluster(postcode) 
 
 
 
 
 outreg2 using Analysis/solargreencorr, bdec(3) se  label   ///
	 tex(fragment pretty) nonotes replace	

 
 
 
 
 
